package com.kedacom.demo.tuscany;

import java.util.Calendar;

import org.oasisopen.sca.annotation.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class FeedServiceImpl implements FeedService {

	private Logger logger = LoggerFactory.getLogger(getClass());

	@Reference
	protected EmailService emailService;

	public Long newFeed(String feed) {
		logger.debug("saved new feed: \"{}\"", feed);
		Long feedId = Math.round(Math.random() * 1000000);

		// send mail
		Email email = new Email();
		email.setId("1");
		email.setSubject("test mail");
		email.setBody("This is a test mail.");
		email.setCreateDateTime(Calendar.getInstance().getTime().toString());
		email.setFrom("致友小秘书 <zhiyou@kedacom.com>");
		email.setTo("罗灿锋 <luocanfeng@kedacom.com>");
		emailService.add(email);

		return feedId;
	}

}
